-
-
Notifications
You must be signed in to change notification settings - Fork 5.7k
inference: Add some basic inference for PhiNode #41115
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
I've been wondering about this for a long long time -- this is great. |
|
I have a couple more fixes here that I'll push shortly. |
| return (vtypes[slot_id(e)]::VarState).typ | ||
| elseif isa(e, GlobalRef) | ||
| return abstract_eval_global(e.mod, e.name) | ||
| elseif isa(e, PhiNode) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it would be better to move this to abstract_eval_statement, since it can't be nested in anything.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok
| deleteat!(sv.stmt_info, i) | ||
| nexpr -= 1 | ||
| if oldidx < length(changemap) | ||
| changemap[oldidx + 1] = -1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wha? Was this a bug?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, the changemap was just offset by one, but as a result, nothing was recorded for the last statement, but here I do need to know if the last statement got deleted (so I can update the relevant phi nodes if any), so I changed the ordering to be non-offset.
3b71aa3 to
7a15866
Compare
PhiNode isn't really supported in lowered IR, but it is convenient to be able to emit it, particularly for code that is designed to perform transformations both on typed and on lowered IR (such as Diffractor). Moreover, we do actually supported phinodes in untyped IR both in the interpreter and in the compiler. At the moment, inference assumes that PhiNodes get treated as embedded constants, which is just not what the actual implementation does. At the very least, it should just leave PhiNodes alone in case they accidentally end up in lowered IR (rather than causing crashes), but we might as well give them some basic support.
|
Per discussion with the compiler team, I'd like to backport this to enable Diffractor and also because the previous behavior is quite arguable a bug. |
PhiNode isn't really supported in lowered IR, but it is convenient to be able to emit it, particularly for code that is designed to perform transformations both on typed and on lowered IR (such as Diffractor). Moreover, we do actually supported phinodes in untyped IR both in the interpreter and in the compiler. At the moment, inference assumes that PhiNodes get treated as embedded constants, which is just not what the actual implementation does. At the very least, it should just leave PhiNodes alone in case they accidentally end up in lowered IR (rather than causing crashes), but we might as well give them some basic support. (cherry picked from commit bb52621)
PhiNode isn't really supported in lowered IR, but it is convenient to be able to emit it, particularly for code that is designed to perform transformations both on typed and on lowered IR (such as Diffractor). Moreover, we do actually supported phinodes in untyped IR both in the interpreter and in the compiler. At the moment, inference assumes that PhiNodes get treated as embedded constants, which is just not what the actual implementation does. At the very least, it should just leave PhiNodes alone in case they accidentally end up in lowered IR (rather than causing crashes), but we might as well give them some basic support.
PhiNode isn't really supported in lowered IR, but it is convenient
to be able to emit it, particularly for code that is designed to
perform transformations both on typed and on lowered IR (such as
Diffractor). Moreover, we do actually supported phinodes in untyped
IR both in the interpreter and in the compiler. At the moment,
inference assumes that PhiNodes get treated as embedded constants,
which is just not what the actual implementation does. At the very
least, it should just leave PhiNodes alone in case they accidentally
end up in lowered IR (rather than causing crashes), but we might
as well give them some basic support.